Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
bin-wrapper
Advanced tools
Binary wrapper that makes your programs seamlessly available as local dependencies
The bin-wrapper npm package is a utility that helps you download and manage binaries for your Node.js projects. It allows you to specify a binary, download it if necessary, and make it available for use in your project. This is particularly useful for ensuring that the correct version of a binary is used, regardless of the environment in which your code is running.
Download and manage binaries
This feature allows you to specify different sources for binaries based on the operating system and architecture. The code sample demonstrates how to set up a BinWrapper instance to download the gifsicle binary for different platforms and run it to check its version.
const BinWrapper = require('bin-wrapper');
const path = require('path');
const base = 'https://raw.githubusercontent.com/imagemin/gifsicle-bin/main/vendor';
const bin = new BinWrapper()
.src(`${base}/macos/gifsicle`, 'darwin')
.src(`${base}/linux/x64/gifsicle`, 'linux', 'x64')
.src(`${base}/win/x64/gifsicle.exe`, 'win32', 'x64')
.dest(path.join(__dirname, 'vendor'))
.use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle');
bin.run(['--version']).then(() => {
console.log('Binary is working');
}).catch(err => {
console.error('Binary failed to run', err);
});
node-pre-gyp is a tool that makes it easy to publish and install Node.js C++ addons from binaries. It provides a way to package and distribute precompiled binaries, which can be downloaded and used without requiring users to compile the code themselves. Compared to bin-wrapper, node-pre-gyp is more focused on C++ addons and their distribution, whereas bin-wrapper is more general-purpose for managing any kind of binary.
nexe is a command-line utility that compiles your Node.js application into a single executable file. It includes the Node.js runtime and your application code, making it easy to distribute and run your application on different systems. While bin-wrapper focuses on downloading and managing external binaries, nexe is about packaging your Node.js application into a standalone binary.
pkg is a tool that packages Node.js projects into executable files for different platforms. It allows you to create a single executable that includes your application code and the Node.js runtime. Similar to nexe, pkg is focused on creating standalone executables, whereas bin-wrapper is about managing external binaries that your project depends on.
Binary wrapper that makes your programs seamlessly available as local dependencies
$ npm install bin-wrapper
const BinWrapper = require('bin-wrapper');
const base = 'https://github.com/imagemin/gifsicle-bin/raw/master/vendor';
const bin = new BinWrapper()
.src(`${base}/macos/gifsicle`, 'darwin')
.src(`${base}/linux/x64/gifsicle`, 'linux', 'x64')
.src(`${base}/win/x64/gifsicle.exe`, 'win32', 'x64')
.dest(path.join('vendor'))
.use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle')
.version('>=1.71');
(async () => {
await bin.run(['--version']);
console.log('gifsicle is working');
})();
Get the path to your binary with bin.path()
:
console.log(bin.path());
//=> 'path/to/vendor/gifsicle'
new BinWrapper(options)
Creates a new BinWrapper
instance.
Type: Object
Type: boolean
Default: false
Whether to skip the binary check or not.
Type: number
Default: 1
Strip a number of leading paths from file names on extraction.
Adds a source to download.
Type: string
Accepts a URL pointing to a file to download.
Type: string
Tie the source to a specific OS.
Type: string
Tie the source to a specific arch.
Type: string
Accepts a path which the files will be downloaded to.
Type: string
Define which file to use as the binary.
Returns the full path to your binary.
Type: string
Define a semver range to check the binary against.
Runs the search for the binary. If no binary is found it will download the file
using the URL provided in .src()
.
Type: Array
Default: ['--version']
Command to run the binary with. If it exits with code 0
it means that the
binary is working.
MIT © Kevin Mårtensson
FAQs
Binary wrapper that makes your programs seamlessly available as local dependencies
We found that bin-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.